import 'package:flutter/material.dart';
import 'package:client/provider/app_provider.dart';
import 'package:client/provider/chat_list_provider.dart';
import 'package:client/provider/chat_msg_provider.dart';
import 'package:client/provider/chatroom_msg_provider.dart';
import 'package:client/provider/chatroom_member_provider.dart';
import 'package:client/view/app.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:provider/provider.dart';
import 'package:window_manager/window_manager.dart';

Future main() async {
  //加载配置
  await dotenv.load(fileName: ".env");
  // await Fun.player.setSourceAsset("tip.mp3");

  WidgetsFlutterBinding.ensureInitialized();
  // Must add this line.
  await windowManager.ensureInitialized();

  WindowOptions windowOptions = const WindowOptions(
    size: Size(1000, 800),
    center: true,
    // backgroundColor: Color.fromARGB(0, 225, 245, 8),
    skipTaskbar: false,
    // titleBarStyle: TitleBarStyle.normal,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.show();
    await windowManager.focus();
  });

  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (context) => AppProvider()),
        ChangeNotifierProvider(create: (context) => ChatroomMemberProvider()),
        ChangeNotifierProvider(create: (context) => ChatroomInfoProvider()),
        ChangeNotifierProvider(create: (context) => ChatListProvider()),
        ChangeNotifierProvider(create: (context) => ChatMsgProvider()),
      ],
      child: const MainApp(),
    ),
  );
}
